package com.dxb.idmr.controller.mobile;

import com.dxb.idmr.service.IPapersService;
import com.dxb.idmr.service.IQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * User: dxb
 * Date: 2020/5/1
 * Description: When I wrote this, only God and I understood what I was doing. Now, God only knows
 */
@Controller
@RequestMapping("/mobile")
public class MobileExamController {
    @Autowired
    IPapersService papersService;
    @Autowired
    IQuestionsService questionsService;
    @Autowired
    HttpServletRequest request;

    @GetMapping("/index")
    public String index(Model model) {
        return "/mobile/index";
    }

    @RequestMapping("/exam")
    public String exam(Model model) {
        if (request.getSession().getAttribute("student") == null) {
            return "/mobile/index";
        }
        return "/mobile/exam";
    }

    @GetMapping("/error")
    public String errors(Model model) {
        return "/mobile/error";
    }

    @GetMapping("/success")
    public String success(Model model) {
        return "/mobile/success";
    }
}
